package cn.sczhyt.modules.szhy.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import cn.sczhyt.modules.szhy.entity.MeetingDinnerEntity;
import cn.sczhyt.modules.szhy.service.MeetingDinnerService;
import cn.sczhyt.common.utils.PageUtils;
import cn.sczhyt.common.utils.R;



/**
 * 会议晚宴
 *
 * @author luojialin
 * @email 78357966@qq.com
 * @date 2021-03-25 13:51:48
 */
@Api(tags = "PC端晚宴安排")
@RestController
@RequestMapping("szhy/meetingdinner")
public class MeetingDinnerController {
    @Autowired
    private MeetingDinnerService meetingDinnerService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = meetingDinnerService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation("晚宴安排列表")
    @RequestMapping("/info/{meetingId}")
    public R info(@PathVariable("meetingId") String meetingId){

		List<MeetingDinnerEntity> list = meetingDinnerService.getByMeetingId(meetingId);

        return R.ok().put("data", list);
    }

    /**
     * 保存
     */
    @ApiOperation("新增晚宴人员")
    @PutMapping("/save")
    public R save(@RequestBody MeetingDinnerEntity meetingDinner){


        meetingDinnerService.saveMeetingUser(meetingDinner);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation("修改晚宴人员")
    @PostMapping("/update")
    public R update(@RequestBody MeetingDinnerEntity meetingDinner){
		meetingDinnerService.updateById(meetingDinner);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation("删除晚宴人员")
    @DeleteMapping("/delete")
    public R delete(@RequestBody String[] dinnerIds){
		meetingDinnerService.removeByIds(Arrays.asList(dinnerIds));

        return R.ok();
    }

}
